package model;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Alexander Shidlovsky
 */
public class ProductType {
    private String name;
    private List<Process> recipe;
    private List<Stack> stacks;

    public ProductType(String name) {
	this.name = name;
	recipe = new ArrayList<Process>();
	stacks = new ArrayList<Stack>();
    }

    public ProductType(String name, ArrayList<Process> p) {
	this(name);

	recipe.addAll(p);
    }

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    // Inserts a new process at the end of the list
    public void addProcess(Process p) {
	recipe.add(p);
    }

    // Inserts a new process at the specified position
    public void addProcess(Process p, int index) {
	recipe.add(index, p);
    }

    public void removeProcess(Process p) {
	recipe.remove(p);
    }

    void addStack(Stack s) {
	if (!stacks.contains(s)) {
	    stacks.add(s);
	}
    }

    void removeStack(Stack s) {
	stacks.remove(s);
    }

    public List<Process> getRecipe() {
	return new ArrayList<Process>(recipe);
    }

    public List<Stack> getStacks() {
	return new ArrayList<Stack>(stacks);
    }

    @Override
    public String toString() {
	return name;
    }

    public void setProcesses(ArrayList<Process> processes) {
	recipe.clear();
	recipe.addAll(processes);
    }

}
